<template>
  <!-- 面包屑组件 -->
  <div class="mian">
    <div @click="msg">
      <el-icon :size="35">
        <fold :class="anim ? 'anim' : 'anims'" />
      </el-icon>
    </div>

    <!-- 面包屑 -->
    <el-breadcrumb separator=">" class="breadcrumb">
      <el-breadcrumb-item :to="{ path: '/Index' }">首页</el-breadcrumb-item>
      <template v-if="$route.path != '/Index'">
        <el-breadcrumb-item v-for="(item, index) in $route.matched.slice(1)" :key="index">{{ item.meta.title }}</el-breadcrumb-item>
      </template>
    </el-breadcrumb>
    <!-- 面包屑结束 -->
  </div>
</template>

<script>
import { Fold } from '@element-plus/icons-vue' // 图标

export default {
  // 注册组件
  components: {
    Fold
  },

  data () {
    return {
      isCollapse: false, // 菜单
      anim: false // 面包屑判断动画
    }
  },
  // 组件传值
  props: ['size'],
  methods: {
    // 菜单
    msg () {
      this.isCollapse = !this.isCollapse
      this.anim = !this.anim
      // 子传父
      this.$emit('top', this.isCollapse)
    }
    // 菜单结束
  },

  // 监听路由
  watch: {
    $route () {}
  }
}
</script>

<style lang="less" scoped>
.mian {
  width: 75%;
  display: flex;
  align-items: center; //图片文字居中
  height: 60px !important;
  padding-left: 20px;
  // background-color: aqua;
  // 面包屑
  .el-icon {
    height: 60px;
    color: #999;
    .anim {
      transition-duration: 0.5s;
      transform: rotate(180deg);
    }
    .anims {
      transition-duration: 0.5s;
      transform: rotate(0deg);
    }
  }
  .el-breadcrumb {
    margin-left: 10px;
  }
  .breadcrumb {
    width: 100%;
  }
}
</style>
